package controller;

import java.awt.Color;
import java.awt.FlowLayout;
import java.awt.Frame;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.util.Scanner;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JTextArea;
import javax.swing.border.EmptyBorder;

public class HelpFrame extends Frame {
	
	public HelpFrame() {
		
		addWindowListener (new WindowAdapter(){
			public void windowClosing(WindowEvent evt){
				close(evt);
			}
		});
		
		this.setTitle("Usage");
		String string = "";
		
		try {
			Scanner in = new Scanner (new FileInputStream("readme.txt"));
			while (in.hasNext())
				string += in.nextLine() + "\n";
			in.close();
			
			JTextArea textArea = new JTextArea(string);
			textArea.setEditable(false);
			
			JPanel container = new JPanel();
			container.setLayout(new FlowLayout(FlowLayout.CENTER));
			container.add(textArea);
			container.setBorder(new EmptyBorder(10, 10, 10, 10));

			add(container);
			pack();
			setVisible(true);
			setResizable(false);
		} catch (FileNotFoundException e) {
			JOptionPane.showMessageDialog(null, "Could not find the file readme.txt", "Error...", JOptionPane.ERROR_MESSAGE);
		}
	}// end of constructor
	
	private void close(WindowEvent e){
		this.dispose();
	}

}// end of class
